package com.xxkk.utils;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Objects;
import java.util.Properties;

/**
 * @Title: ResourceUtils
 * @Description: ^_^
 * @Author: xxkk
 * @Date: 2023年10月6日 上午9:58:29
 */

public class ResourcesRootPathUtil {
	// 获取当前工作目录的绝对路径，然后在此基础上指定相对路径
	public static Properties read(String fileName) {
		Properties props = new Properties();
		try {
			InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
			props.load(inputStream);
			inputStream.close();
		} catch (IOException e) {
			e.printStackTrace();
			throw new RuntimeException();
		}
		return props;
	}

	public static String getResourcePath() {
		return ResourcesRootPathUtil.class.getClassLoader().getResource("").getPath();
	}
	public static String getUserDir() {
		return System.getProperty("user.dir");
	}

}
